<include file="Public:header"/>
<!--新货位添加-->
<div class="cat">
<form method="POST" action="__URL__/add">
	   <select size="1" name="pid">
		   <option value='0'>顶级货位</option>
<volist name="place_list" id="place_list">
		   <option value="{$place_list.place_id}">{$place_list.fullname}</option>
</volist>
	  </select>

	货位：<input type="text" name="name" size="20">
	<input type="submit" value="添加货位" name="B1">
</form>
</div>


<!--货位列表-->
<div class="cat" style="margin-top:5px;">
<table bordercolor="#DDDFFF" border="1" width="100%" style="border-collapse: collapse" cellpadding="3">
	<tr height="17" align="center">
		<td class="title" width="40">排序</td>
		<td class="title" width="300">分类名称</td>

		<td class="title" width="40">修改</td>
		<td class="title" width="40">删除</td>

		<td class="title">　</td>
	</tr>
<volist name="place_list2" id="place_list2">

	<tr height="20" bgcolor="#F1F5FA" class="cat_list">
		<td width="40">
		<input type="text" name="place_id[]" value="{$place_list2.place_id}" style="display:none">
		<input name="sorting[]" size="10" type="text" value="{$place_list2.sorting}"></td>
<if condition="$place_list2.parent eq 0">
		<td width="300" style="font-weight:bold">[{$place_list2.fullname}]</td>
<else/>
        <td width="300">{$place_list2.fullname}</td>
</if>

		<td width="40" align="center"><a href="__URL__/edit/?place={$place_list2.place_id}"><img src="__APP__/statics/icons/member3.gif"></a></td>
		<td width="40" align="center"><a href="javascript:;" onclick="deletePlace({$place_list2.place_id})"><img alt="删除" src="__APP__/statics/icons/icon_delete.gif"></a></td>

		<td></td>
	</tr>
</volist>
</table>
</div>
<br><br><br>
<div id="save"><input id="save_sort" type="button" value="保存排序"></div>

<script>
$(function(){
    $("#save_sort").click(function(){
              var place_id=[];
			  $("[name='place_id[]']").each(function(){
                     place_id.push($(this).val()); 
               }); 
			  var sorting=[];
			  $("[name='sorting[]']").each(function(){
                     sorting.push($(this).val()); 
               }); 
			   $.ajax({
			         type:"POST",
					 url:"__URL__/sorting",
					 dataType:"html",
					 data:{'place_id':place_id,'sort':sorting},
					 success:function(data){
					 }
			   })
			  location.reload();
	})
})

function deletePlace(t){
	if(confirm('你确认删除此模型吗？')) {
		$.get('__URL__/deletePlace',{'place_id':t},function(res){
			location.reload();
		})
	}
}
</script>


